--- title: "美丽的2" created: 2025-11-28 tags: - 算法 --- # 美丽的2 ## 题目 [美丽的2](https://www.lanqiao.cn/paper/3839/problem/1018/) ![[image-0550c518.png]] ## 思路分析 直接枚举1~2020 对每个数进行拆分 老朋友了 ## 代码实现 ```cpp #include using namespace std; #define endl '\n' int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int cnt=0; for(int i=1;i<=2020;i++){ int x=i; bool flag=false; while(x){ if(x%10==2) flag=true; x/=10; } if(flag) cnt++; } cout<